package njust.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import njust.dao.RespondDao;
import njust.domain.Image;
import njust.domain.Respond;

public class RespondDaoImpl extends HibernateDaoSupport implements RespondDao {

	@Override
	public boolean addRespond(Respond respond) {
		this.getHibernateTemplate().save(respond);
		return true;
	}

	@Override
	public boolean deleteRespond(int id) {
		Respond respond = (Respond) this.getHibernateTemplate().get(
				Respond.class, id);
		this.getHibernateTemplate().delete(respond);
		return true;
	}

	@Override
	public List getAllRespond() {
		List list = new ArrayList();
		// this.getHibernateTemplate().setCacheQueries(true);
		list = this.getHibernateTemplate()
				.find("from Respond order by Id desc");
		return list;
	}

	@Override
	public Respond getRespondById(int id) {
		Respond respond = (Respond) this.getHibernateTemplate().get(
				Respond.class, id);
		return respond;
	}

}
